package ch03.test;

import org.apache.log4j.Logger;

import java.lang.reflect.InvocationHandler;
import java.lang.reflect.Method;

public class GuestInvocationHandler implements InvocationHandler {
    private Logger logger=Logger.getLogger(GuestInvocationHandler.class);

    private Object target;

    public void setTarget(Object target) {
        this.target = target;
    }

    @Override
    public Object invoke(Object proxy, Method method, Object[] args) throws Throwable {
        before();
        Object invoke = method.invoke(target, args);
        after();
        return "总结:"+invoke;
    }
    public void before(){
        logger.debug("喝茶");
        logger.debug("聊天");
        logger.debug("吃饭");
    }
    public void after(){
        logger.debug("送客");
    }
}
